import multiprocessing
import os

from dotenv import load_dotenv

load_dotenv()

# path
BASE_DIR = os.path.abspath(os.path.dirname(__file__))
STATIC_PATH = os.path.join(BASE_DIR, 'static')
# UPLOADS_PATH = os.path.join(BASE_DIR, 'uploads')

# csrf
WTF_CSRF_ENABLED = True if 'True' == os.getenv('WTF_CSRF_ENABLED') else False

# log
LOG_PATH = os.path.join(BASE_DIR, 'logs')
LOG_PATH_ERROR = os.path.join(LOG_PATH, 'error.log')
LOG_PATH_INFO = os.path.join(LOG_PATH, 'info.log')
LOG_FILE_MAX_BYTES = 100 * 1024 * 1024
LOG_FILE_BACKUP_COUNT = 10

# db
PONY = {
    'provider': 'mysql',
    'host': os.getenv('PONY_HOST'),
    'user': os.getenv('PONY_USER'),
    'password': os.getenv('PONY_PASSWORD'),
    'db': os.getenv('PONY_DB')
}

# celery
CELERY = {
    'broker_url': os.getenv('CELERY_BROKER_URL'),
    'result_backend': os.getenv('CELERY_RESULT_BACKEND'),
    'timezone': os.getenv('CELERY_TIMEZONE'),
    'worker_concurrency': multiprocessing.cpu_count(),
    'worker_disable_rate_limits': True,
    'worker_max_tasks_per_child': 500,
    # 'task_soft_time_limit': 30,
    # 'task_time_limit': 40,
}

# oss
OSS_ACCESS_KEY_ID = os.getenv('OSS_ACCESS_KEY_ID')
OSS_SECRET_ACCESS_KEY = os.getenv('OSS_SECRET_ACCESS_KEY')
OSS_ENDPOINT = os.getenv('OSS_ENDPOINT')
OSS_BUCKET_NAME = os.getenv('OSS_BUCKET_NAME')
OSS_BASE_PATH = os.getenv('OSS_BASE_PATH')
OSS_URL_DOMAIN = os.getenv('OSS_URL_DOMAIN')

# local api
